package com.bytecollege.service;

import com.bytecollege.mapper.UserMapper;
import com.bytecollege.model.User;
import com.bytecollege.service.Impl.CremarkServiceImpl;
import com.bytecollege.service.Impl.UserServiceImpl;
import com.bytecollege.util.ValidateCodeUtils;
import lombok.extern.java.Log;
import org.junit.jupiter.api.Test;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Date;

/**
 * @ClassName: userMpperText
 * @Description:
 * @Author: Sun
 * @Date: 2022/10/20 9:20
 */

@SpringBootTest
@Log
public class userServiceText {
      @Autowired
    private UserServiceImpl userService;


      @Test
      public void reg(){
          User user = new User();
          user.setUserName("孙树辉");
          user.setUserPwd("11111");
          user.setUserBirthday("fghwrt");
          userService.reg(user);

      }
//      @Test
//      public void login(){
//          User login = userService.login("孙树辉", "121212");
//          log.info(login.toString());
//
//      }


    @Test
    public void getbyUId(){
        User byId = userService.getById(11);
        log.info(byId.toString());
    }

    @Test
    public void updatePassword(){
        userService.updatePassword(11,"11111","121212");

    }


    @Test
    public void updateInfo(){

        User user = new User();
        user.setUserName("hhh");
        user.setUserBirthday("");
        user.setUserEmail("2012@qq.com");
        user.setUserGender("男");
        user.setUserPhone("12321541243");
        user.setUserId(11);
       userService.updateInfo(user);

    }

    @Test
    public void msg(){
        String code = ValidateCodeUtils.generateValidateCode(4).toString();
        String context = "欢迎使用Byte云课，登录验证码为: " + code + ",五分钟内有效，请妥善保管!";
        log.info(code);
          userService.sendMsg("1281238306@qq.com","Byte云课登录验证码",context);
    }




}
